package com.leetCode.problem;

import java.sql.Time;
import java.util.Collection;
import java.util.Iterator;
import java.util.concurrent.*;

/**
 * Description:
 * Copyright:   Copyright (c)2019
 * Company:     zefu
 *
 * @author: 张李鑫
 * @version: 1.0
 * Create at:   2021-11-24 14:58:12
 * <p>
 * Modification History:
 * Date         Author      Version     Description
 * ------------------------------------------------------------------
 * 2021-11-24     张李鑫                     1.0         1.0 Version
 */
public class Problem53 {

    public static int maxSubArray(int[] nums) {
        return process(nums, 0, nums.length - 1);
    }

    private static int process(int[] nums, int i, int end) {
        if (nums.length == i || end < 0) {
            return 0;
        }
        int p1 = nums[i] + process(nums, i + 1, end);
        int p2 = nums[end] + process(nums, i, end - 1);
        return Math.max(p1, p2);
    }

    public static void main(String[] args) throws InterruptedException {
        BlockingDeque<Runnable> que = new LinkedBlockingDeque<>();
        CountDownLatch countDownLatch = new CountDownLatch(4);
        countDownLatch.countDown();
        countDownLatch.await();
//        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(10, 10, 2000, TimeUnit.HOURS,que);
//        threadPoolExecutor.execute();
        int[] arr = { -2,1,-3,4,-1,2,1,-5,4};
        System.out.println(maxSubArray(arr));
    }
}
